package cn.qingxuntech.console.config

import cn.hutool.core.util.StrUtil
import com.p6spy.engine.spy.appender.MessageFormattingStrategy

class P6SpyLogger : MessageFormattingStrategy {
    override fun formatMessage(
        connectionId: Int,
        now: String,
        elapsed: Long,
        category: String?,
        prepared: String?,
        sql: String,
        url: String?
    ): String? {
        return if (StrUtil.isNotEmpty(sql)) """ Consume Time：$elapsed ms $now
 Execute SQL：${sql.replace("[\\s]+".toRegex(), " ")}
""" else null
    }
}